<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="90px">
      <el-form-item label="设备类别" prop="equipCateg">
        <el-input v-model="queryParams.equipCateg" placeholder="请输入设备类别" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="设备条形码" prop="barCode">
        <el-input v-model="queryParams.barCode" placeholder="请输入设备条形码" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-table v-loading="loading" :data="otherMaterialList" @selection-change="handleSelectionChange">
      <el-table-column label="其他物资id" align="center" prop="otherMaterialId" />
      <el-table-column label="设备类别" align="center" prop="equipCateg" />
      <el-table-column label="设备标识" align="center" prop="equipId" />
      <el-table-column label="设备条形码" align="center" prop="barCode" />
      <el-table-column label="库房标识" align="center" prop="whId" v-if="false" />
      <el-table-column label="库房名称" align="center" prop="whName" />
      <el-table-column label="库区标识" align="center" prop="whAreaId" v-if="false" />
      <el-table-column label="库区名称" align="center" prop="whAreaname" />
      <el-table-column label="存放区标识" align="center" prop="storeAreaId" v-if="false" />
      <el-table-column label="存放区名称" align="center" prop="storeAreaName" />
      <el-table-column label="柜单元标识" align="center" prop="unitId" v-if="false" />
      <el-table-column label="储位标识" align="center" prop="storeLocId" v-if="false" />
      <el-table-column label="储位名称" align="center" prop="storeLocName" />
      <el-table-column label="状态" align="center" prop="status">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.om_status" :value="scope.row.status" />
        </template>
      </el-table-column>
      <el-table-column label="删除标识" align="center" prop="delflag" v-if="false">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.om_deflag" :value="scope.row.delflag" />
        </template>
      </el-table-column>
    </el-table>

    <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
      @pagination="getList" />
  </div>
</template>

<script>
import { listOtherMaterial } from "@/api/storage/otherMaterial";

export default {
  name: "OtherMaterial",
  dicts: ["om_status", "om_deflag"],
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 其他物资表格数据
      otherMaterialList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        equipCateg: null,
        barCode: null
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询其他物资列表 */
    getList() {
      this.loading = true;
      listOtherMaterial(this.queryParams).then(response => {
        this.otherMaterialList = response.rows;
        console.log(response)
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        otherMaterialId: null,
        equipCateg: null,
        equipId: null,
        barCode: null,
        whId: null,
        whAreaId: null,
        storeAreaId: null,
        unitId: null,
        storeLocId: null,
        status: 0,
        delflag: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    }
  }
};
</script>
